package ai.people.netmon.framework.businessenum.warning;

import java.util.Arrays;
import java.util.Optional;

/**
 * 预警导出状态
 *
 * @author 李冠男
 * @date 2022/5/31 15:57
 */
public enum WarningExportDownloadStateEnum {

    /**
     * 导出中
     */
    EXPORTING(1, "导出中"),
    /**
     * 导出完成
     */
    EXPORTED(2, "导出完成"),
    ;

    private final int code;

    private final String name;

    WarningExportDownloadStateEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static WarningExportDownloadStateEnum parseCode(Integer code){
        Optional<WarningExportDownloadStateEnum> first = Arrays.stream(WarningExportDownloadStateEnum.values()).filter(o -> o.getCode() == code).findFirst();
        if(first.isPresent()){
            return first.get();
        }
        return null;
    }
}
